﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text;
using System.Threading.Tasks;
using WCFServiceWebRole1.Services;

namespace IotWebServiceSelfHost
{
    class Program
    {
        static void Main(string[] args)
        {
            string baseaddr = "http://localhost:8000/Services/users.svc";
            Uri baseAddress = new Uri(baseaddr);

            // define and add your own endpoints here

            // Create the ServiceHost.
            ServiceHost host = new ServiceHost(typeof(user));
                

                //host.AddServiceEndpoint(typeof(Iusers), new WebHttpBinding(), ""); 
                //host.AddServiceEndpoint(typeof(Iusers), new WebHttpBinding(), "users.svc");
                // add all the system default endpoints to your host
                host.AddDefaultEndpoints();
                //var smb = new ServiceMetadataBehavior();
                //smb.HttpGetEnabled = true;
                //host.Description.Behaviors.Add(smb);
                //for some reason a default endpoint does not get created here
                host.Open();
                WebChannelFactory<Iusers> factory = new WebChannelFactory<Iusers>(new Uri(baseaddr));
                factory.Endpoint.Behaviors.Add(new WebHttpBehavior());
                Iusers proxy = factory.CreateChannel();
                Console.WriteLine(proxy.getUserByUserId("1092").response.Username.ToString());
                Console.WriteLine("Service Running.  Press any key to stop.");
                Console.ReadKey();
                // here, you should now have your own endpoints, plus 
                // one endpoint for each contract and binding
            

        }
    }
}
